home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS24.ADF / BNTools / SetLace.ASM < prev    next >
Assembly Source File  |  1988-04-16  |  5KB  |  143 lines

  1. ;tabs every 8
  2. ;
  3. ;SetLace implementation by Bryce Nesbitt, based on an example by Bob
  4. ;Pariseau of C-A. Public Domain.
  5. ;
  6. ;On most monitors a non-interlaced display will leave black bars between
  7. ;each scan line.  This is evident in all the 200 line display modes of the
  8. ;Amiga 1000.  For photographs or longer persistence displays this black is
  9. ;undesirable.  SetLace instructs the system to set interlace; on each
  10. ;successive field the same display data will be painted in between that of 
  11. ;the previous field.  This may be a necessity for use of the Amiga with
  12. ;some NTSC video gear and broadcast television equipment.  For most computer
  13. ;(non-broadcast) applications interlace will flicker unacceptably unless
  14. ;the contrast, brightness and room lighting are all turned way down.
  15. ;
  16. ;CLI Syntax:    SetLace        ;Flip (XOR) interlace
  17. ;        SetLace 1    ;Turn lace on
  18. ;        SetLace 0    ;Turn lace off
  19. ;Workbench:            ;Flip (XOR)
  20. ;ALL screens will be forced to interlace
  21. ;
  22. ;Author correspondence, bug or stupidity reports may be directed to:
  23. ;    Bryce Nesbitt
  24. ;    1712 Marin Ave.
  25. ;    Berkeley, Ca 94707-2902
  26. *************************
  27.     NOLIST
  28.     INCLUDE 'exec/types.i'
  29.     INCLUDE 'libraries/dosextens.i'
  30.     INCLUDE 'graphics/display.i'
  31.     INCLUDE 'graphics/gfxbase.i'
  32.     ;INCLUDE 'lib/exec_lib.i'    ;eliminates link with amiga.lib
  33.     ;INCLUDE 'lib/dos_lib.i'    ;non-standard, and very speedy!
  34.     ;INCLUDE 'lib/intuition_lib.i'    ;Can be fabricated from the fd.files
  35.     ;INCLUDE 'lib/graphics_lib.i'    ;directory. (see exec/exec_lib.i)
  36.     LIST
  37. jsrlib    macro
  38.     xref    _LVO\1            ;^Nuke for use as above^
  39.     jsr    _LVO\1(a6)
  40.     endm
  41. jmplib    macro
  42.     xref    _LVO\1
  43.     jmp    _LVO\1(a6)
  44.     endm
  45. **************************
  46.         CODE
  47. startup:    move.l    a0,a4        ;CLI line pointer
  48.         move.l    d0,d4        ;CLI line length
  49.         move.l    4,a6
  50.         suba.l    a1,a1        ;Get THIS task
  51.         jsrlib    FindTask
  52.         move.l    d0,a5
  53.         moveq    #0,d0        ;Set zero for later
  54.         move.l    pr_CLI(a5),d1    ;Pointer to CLI only structure
  55.         bne.s    fromCLI        ;If not zero, then save a zero...
  56. ;
  57. ; If called from Workbench a message will be sent.  This waits for it,
  58. ;  and saves it's pointer to be returned to Workbench later.
  59. ;
  60.         lea    pr_MsgPort(a5),a0
  61.         jsrlib    WaitPort
  62.         lea    pr_MsgPort(a5),a0
  63.         jsrlib    GetMsg        ;Message pointer in D0
  64.         moveq    #0,d4        ;clear CLI line pointer
  65. fromCLI     move.l    d0,-(a7)    ;Save message for later...
  66.  
  67.  
  68. ******************************** [A6=ExecBase][a5=this task][a4=CLI line]
  69. * [d4=CLI length]
  70. returncode    equr    d7
  71. ibase        equr    d6
  72. gbase        equr    d5
  73. * (d4,a4,a5)
  74.  
  75.         moveq    #20,returncode    ;default to 'severe failure' code
  76.         lea    IntuiName(pc),a1
  77.         moveq    #0,d0
  78.         jsrlib    OpenLibrary
  79.         move.l    d0,ibase     ;Error check. What a pain! Could we
  80.         beq.s    e_Intui         ;not agree that Intuition and a few
  81.         lea    Graphname(pc),a1 ;other core libraries will always
  82.         moveq    #0,d0         ;be openable??
  83.         jsrlib    OpenLibrary
  84.         move.l    d0,gbase
  85.         beq.s    e_Graph
  86. ;
  87. ;Modifying the system-wide bplcon0.  From here we can change all screens
  88. ;to INTERLACE and turn tricks like disabling colorburst.  The Forbid/
  89. ;Permit pair is used for saftey while modifying this stuff.
  90. ;
  91.         jsrlib    Forbid
  92.         move.l    gbase,a6    ;gbase
  93.  
  94.         subq.l    #2,d4        ;0=wb 1=cli no args 2=1 arg
  95.         bmi.s    flip        ;wb, or cli flip
  96.         bne.s    toomanychars
  97.         cmpi.b    #'0',(a4)
  98.         beq.s    clear
  99.         cmpi.b    #'1',(a4)
  100.         bne.s    badargs
  101.  
  102. setlace        ori.w    #INTERLACE,gb_system_bplcon0(a6)    ;Set lace
  103.         bra.s    break
  104. clear        andi.w    #$ffff-INTERLACE,gb_system_bplcon0(a6)    ;Clear lace
  105.         bra.s    break
  106. flip        eori.w    #INTERLACE,gb_system_bplcon0(a6)     ;Flip lace
  107.  
  108. break        move.l    ibase,a6
  109.         jsrlib    RemakeDisplay    ;The big one! Rethink ALL displays
  110.         moveq    #0,returncode    ;Everything is OK!
  111.         bra.s    goodexit
  112. badargs
  113. toomanychars    move.l    #120,pr_Result2(a5) ;'arg line invalid or too long'
  114.         moveq    #10,d7        ;return code 10, less serious error
  115. goodexit    move.l    4,a6
  116.         jsrlib    Permit
  117. ;
  118. ;RemakeDisplay() is spec'ed to do a Forbid() and then Permit() around it's
  119. ; lengthy operation. This is just a saftey valve in case it did not...
  120. ;
  121.         move.l    gbase,a1
  122.         jsrlib    CloseLibrary
  123. e_Graph        move.l    ibase,a1
  124.         jsrlib    CloseLibrary
  125. e_Intui
  126. ******************************** (a7)+=message d7=return code
  127. ExitToDOS    move.l    (a7)+,d6
  128.         beq.s    NotWB    ;If saved pointer is zero, exit to CLI...
  129. ;
  130. ; Return the startup message to the parent Workbench tool. The forbid
  131. ; is needed so workbench can't UnLoadSeg() the code too early.
  132. ;
  133.         move.l    4,a6
  134.         jsrlib    Forbid
  135.         move.l    d6,a1        ;message pointer
  136.         jsrlib    ReplyMsg
  137. NotWB        move.l    d7,d0        ;Set "failat" code
  138.         rts
  139. IntuiName    dc.b   'intuition.library',0
  140. Graphname    dc.b  'graphics.library',0
  141. MyName        dc.b 'Bryce Nesbitt'
  142. ;-- this is the end --
  143.